local thbattle__sp_fulanduolu_pohuaichongdong = fk.CreateSkill {

  name = "thbattle__sp_fulanduolu_pohuaichongdong",

  tags = { Skill.Compulsory, },

}



thbattle__sp_fulanduolu_pohuaichongdong:addEffect(fk.EventPhaseEnd, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__sp_fulanduolu_pohuaichongdong.name) and player.phase == Player.Finish and
        #player.room.logic:getActualDamageEvents(1, function(e)
          local damageEvent = e.data
          return damageEvent.from == player
        end, Player.HistoryTurn) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local other_players = room:getOtherPlayers(player)
    local luanwu_targets = table.map(table.filter(other_players, function(p2)
      return table.every(other_players, function(p1)
        return target:distanceTo(p1) >= target:distanceTo(p2)
      end)
    end), function(p)
      return p.id
    end)
    local target_player = room:askForChoosePlayers(player, luanwu_targets, 1, 1,
      "#thbattle__sp_fulanduolu_pohuaichongdong"
      , thbattle__sp_fulanduolu_pohuaichongdong.name, false)[1]
    room:damage({
      from = player,
      to = room:getPlayerById(target_player),
      damage = 1,
      skillName = thbattle__sp_fulanduolu_pohuaichongdong.name
    })
    room:loseHp(player, 1, thbattle__sp_fulanduolu_pohuaichongdong.name)
  end
})

return thbattle__sp_fulanduolu_pohuaichongdong